let log = document.querySelector(`.header .log`)
log.addEventListener(`click`, function (e) {
  e.preventDefault()
})
// 头部
let contentboxall = document.querySelectorAll(`.container .content-box`)
let container = document.querySelector(`.container `)
let tabul = document.querySelector(`.header .tab ul`)
let tabdiv = document.querySelectorAll(`.header .tab div`)
let line = document.querySelector(`.header .tab .line`)
let types = document.querySelector(`.header .types`)
let Xiala = document.querySelectorAll(`.header .types .xiala`)
let focusimg = document.querySelector(`.content-box .focus img`)
tabul.addEventListener(`click`, function (e) {
  // console.log(e.target.tagName);
  if (e.target.tagName == 'DIV') {
    let name = e.target.dataset.name
    // console.log(e.target);
    for (let i = 0; i < contentboxall.length; i++) {
      contentboxall[i].style.display = `none`;
    }
    let block = document.querySelector(`.container` + " " + "." + name)
    block.style.display = `block`
    for (let i = 0; i < tabdiv.length; i++) {
      tabdiv[i].classList.remove(`active`)
    }
    e.target.classList.add(`active`)
    container.style.marginTop = "2.6667rem"
    if (e.target.dataset.name == "tuijian") {
      types.style.display = `none`
      line.style.left = ".3267rem";
    } else {
      container.style.marginTop = (120 / 37.5) + "rem"
      types.style.display = `flex`
      let left = ((e.target.offsetLeft) / 37.5) + 0.6 + "rem"
      line.style.left = left;
    }
  }

})
types.addEventListener(`click`, function (e) {
  if (e.target.tagName == "LI") {
    let id = e.target.dataset.id
    let xiala = document.querySelector(`.header .types` + " ." + id)
    for (let i = 0; i < Xiala.length; i++) {
      // console.log(Xiala[i].dataset.id);
      if (Xiala[i].dataset.id == id) {
      } else {
        Xiala[i].classList.remove(`active`)
      }
    }
    xiala.classList.toggle(`active`)
    xiala.style.top = (e.target.offsetTop / 37.5) + 0.7 + "rem"
  }
})
let count = 1;
setInterval(function () {
  count++
  if (count == 5) {
    count = 1
  }
  focusimg.src = "./update/focus" + count + ".webp"

}, 1000)
